﻿@model ZhongheCms.Models.GswTblJobInfoAll
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var strChk = "";
  
    if (Model.ReFlag == 1)
    {
        strChk = "checked";
    }

    var strSelect = "";
    var chkName = "";
}
@section css{

    <link rel="stylesheet" href="/kindeditor/themes/default/default.css" />
    <link rel="stylesheet" href="/Assets/webuploader/webuploader.css" />
    <link href="/Assets/css/select2.css" rel="stylesheet">
    <link href="/Assets/css/select2-bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="/Assets/css/datepicker.css" />
}
<div class="row">
    <div class="col-xs-12 col-sm-12 widget-container-col">
        @using (Html.BeginForm("Create", "JobInfoAll", new { id = Model.Id, ViewBag.m, ViewBag.f, ViewBag.p, ViewBag.fid, ViewBag.sdate, ViewBag.edate, ViewBag.jname, ViewBag.pageIndex }, FormMethod.Post,
            new { name = "myForm", id = "myForm", @class = "form-horizontal", role = "form" }))
        {
            <div class="widget-box">
                <div class="widget-header">
                    <h5 class="widget-title">
                        @ViewBag.f  @if (!string.IsNullOrEmpty(ViewBag.p))
                        {
                            <span>(@ViewBag.p)</span>
                        }
                    </h5>

                    <div class="widget-toolbar">
                    </div>
                </div>

                <div class="widget-body">


                    <div class="widget-main">

                        <div class="form-group">
                            <table id="sample-table-1" class="table table-bordered table-hover">
                                <tbody>
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            发布日期
                                        </td>
                                        <td>

                                            <input id="PubDate" name="PubDate" placeholder="" type="text" class="form-control" value="@Model.PubDate.ToShortDateString()" />

                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            招聘截止
                                        </td>
                                        <td>

                                            <input id="EndDate" name="EndDate" placeholder="" type="text" class="form-control" value="@Model.EndDate.ToShortDateString()" />

                                        </td>

                                    </tr>
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            招聘单位
                                        </td>
                                        <td>
                                            <input id="CustomerId" name="CustomerId" placeholder="" type="text" class="form-control" value="@Model.CustomerId" data-val="true" data-val-required="招聘单位不允许为空" />
                                            <span class="field-validation-valid help-block" data-valmsg-for="CustomerId" data-valmsg-replace="true"></span>



                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            工作地点
                                        </td>
                                        <td>

                                            <input type="text" id="WorkPlace" name="WorkPlace" placeholder="" class="form-control" value="@Model.WorkPlace" />


                                        </td>

                                    </tr>
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            职位类别
                                        </td>
                                        <td>
                                            
                                            <input type="hidden" id="JobType" name="JobType" value="@Model.JobType"/>

                                            <select class="form-control" id="JobTypeId" name="JobTypeId">

                                                @foreach (var item in Model.JobBaseInfos.Where(x => x.FunctionId == 120))
                                                {
                                                    <optgroup label="@item.MasterType">
                                                        @foreach (var subitem in item.BaseInfos)
                                                        {
                                                            strSelect = "";
                                                            if (Model.JobTypeId== subitem.Id)
                                                            {
                                                                strSelect = "selected";
                                                            }
                                                            <option value="@subitem.Id" @strSelect>@subitem.SubType</option>
                                                        }
                                                    </optgroup>

                                                }


                                            </select>


                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            职位名称
                                        </td>
                                        <td>
                                            <input type="text" id="JobName" name="JobName" value="@Model.JobName" class="form-control" data-val="true" data-val-required="职位名称不允许为空" />
                                            <span class="field-validation-valid help-block" data-valmsg-for="JobName" data-valmsg-replace="true"></span>

                                        </td>


                                    </tr>
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            招聘数量
                                        </td>
                                        <td>
                                            <input type="text" id="JobNum" name="JobNum" placeholder="" class="form-control" data-val="true" data-val-number="招聘数量为非法的数字格式" data-val-regex="招聘数量为非法的数字格式"
                                                   data-val-regex-pattern="^(-?\d+)(\.\d+)?$" data-val-required="招聘数量为非法的数字格式" value="@Model.JobNum" />

                                            <span class="field-validation-valid help-block" data-valmsg-for="JobNum" data-valmsg-replace="true"></span>
                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            薪资范围
                                        </td>
                                        <td>

                                            
                                            <select class="form-control" id="SalaryRange" name="SalaryRange">

                                                @foreach (var item in Model.JobBaseInfos.Where(x => x.FunctionId ==122))
                                                {

                                                    strSelect = "";
                                                    if (!string.IsNullOrEmpty(Model.SalaryRange))
                                                    {
                                                        if (Model.SalaryRange.Trim() == item.MasterType.Trim())
                                                        {
                                                            strSelect = "selected";    
                                                        }
                                                        
                                                    }
                                                    <option value="@item.MasterType" @strSelect>@item.MasterType</option>
                                                }

                                                
                                            </select>





                                        </td>

                                    </tr>

                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            性别要求
                                        </td>
                                        <td>
                                            
                                            <select class="form-control" id="GenderReq" name="GenderReq">

                                                @foreach (var item in Model.JobBaseInfos.Where(x => x.FunctionId == 131))
                                                {

                                                    strSelect = "";
                                                    if (!string.IsNullOrEmpty(Model.GenderReq))
                                                    {
                                                        if (Model.GenderReq.Trim() == item.MasterType.Trim())
                                                        {
                                                            strSelect = "selected";
                                                        }

                                                    }
                                                    <option value="@item.MasterType" @strSelect>@item.MasterType</option>
                                                }

                                                
                                            </select>


                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            学历要求
                                        </td>
                                        <td>
                                            

                                            <select class="form-control" id="EduBackground" name="EduBackground">

                                                @foreach (var item in Model.JobBaseInfos.Where(x => x.FunctionId == 132))
                                                {

                                                    strSelect = "";
                                                    if (!string.IsNullOrEmpty(Model.EduBackground))
                                                    {
                                                        if (Model.EduBackground.Trim() == item.MasterType.Trim())
                                                        {
                                                            strSelect = "selected";
                                                        }

                                                    }
                                                    <option value="@item.MasterType" @strSelect>@item.MasterType</option>
                                                }

                                                
                                            </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            工作经验
                                        </td>
                                        <td>

                                          

                                            <select class="form-control" id="WorkExpe" name="WorkExpe">

                                                @foreach (var item in Model.JobBaseInfos.Where(x => x.FunctionId == 130))
                                                {

                                                    strSelect = "";
                                                    if (!string.IsNullOrEmpty(Model.WorkExpe))
                                                    {
                                                        if (Model.WorkExpe.Trim() == item.MasterType.Trim())
                                                        {
                                                            strSelect = "selected";
                                                        }

                                                    }
                                                    <option value="@item.MasterType" @strSelect>@item.MasterType</option>
                                                }


                                            </select>

                                        </td>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            职位推荐
                                        </td>
                                        <td>
                                            <input type="checkbox" id="ReFlag" name="ReFlag" value="1" @strChk />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            职位描述
                                        </td>
                                        <td colspan="3">
                                            <textarea id="JobDesc" name="JobDesc" class="form-control" style="height: 200px">@Model.JobDesc</textarea>
                                        </td>

                                    </tr>
                                    <tr>
                                        <td class="align-right" style="width: 15%; background: #f6f6f6">
                                            职位要求
                                        </td>
                                        <td colspan="3">
                                            <textarea id="JobReq" name="JobReq" class="form-control" style="height: 200px">@Model.JobReq</textarea>

                                        </td>




                                    </tr>



                                </tbody>
                            </table>
                        </div>


                        @if (ViewBag.scode == "1")
                        {
                            <div class="hr hr-2 dotted"></div>
                            <div class="alert alert-success">
                                <button type="button" class="close" data-dismiss="alert">
                                    <i class="icon-remove"></i>
                                </button>

                                <strong>
                                    <i class="icon-ok"></i>
                                    提示信息
                                </strong>

                                信息保存成功!

                            </div>
                        }
                        @if (ViewBag.scode == "0")
                        {
                            <div class="hr hr-2 dotted"></div>
                            <div class="alert alert-danger">
                                <button type="button" class="close" data-dismiss="alert">
                                    <i class="icon-remove"></i>
                                </button>

                                <strong>
                                    <i class="icon-remove"></i>
                                    错误提示
                                </strong>

                                @Html.ValidationSummary(true)

                            </div>

                        }
                        <div class="clearfix form-actions">
                            <div class="col-md-offset-3 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    &nbsp;&nbsp;<i class="ace-icon fa fa-check bigger-110"></i>
                                    保存&nbsp;&nbsp;
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="button" onclick="funBack()">
                                    &nbsp;&nbsp;<i class="ace-icon fa fa-undo bigger-110"></i>
                                    返回&nbsp;&nbsp;
                                </button>
                            </div>
                        </div>




                    </div>



                </div>

            </div>
        }

    </div>


</div>
@section js{
    <script src="/assets/js/jquery.validate.min.js"></script>
    <script src="/assets/js/jquery.validate.unobtrusive.js"></script>
    <script src="/assets/js/jquery.validate.unobtrusive.bootstrap.js"></script>
    <script src="/assets/js/select2.js"></script>
    <script src="/assets/js/select2_locale_zh-CN.js"></script>
    <script charset="utf-8" src="/kindeditor/kindeditor-min.js" type="text/javascript"></script>
    <script charset="utf-8" src="/kindeditor/lang/zh_CN.js" type="text/javascript"></script>
    <script src="/Assets/webuploader/webuploader.js" type="text/javascript"></script>
    <script src="/assets/js/date-time/bootstrap-datepicker.min.js"></script>
    <script src="/assets/js/date-time/bootstrap-datepicker.zh-CN.js"></script>
    <script type="text/javascript">
        KindEditor.ready(function (K) {
            var editor1 = K.create('#JobDesc', {
                cssPath: '/kindeditor/plugins/code/prettify.css',
                uploadJson: '/kindeditor/upload_json.ashx',
                fileManagerJson: '/kindeditor/file_manager_json.ashx',
                items: [
                      'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                      'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                      'insertunorderedlist', '|', 'emoticons', 'image', 'link'],


            });
            var editor2 = K.create('#JobReq', {
                cssPath: '/kindeditor/plugins/code/prettify.css',
                uploadJson: '/kindeditor/upload_json.ashx',
                fileManagerJson: '/kindeditor/file_manager_json.ashx',
                items: [
						'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
						'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
						'insertunorderedlist', '|', 'emoticons', 'image', 'link'],


            });

        });


        jQuery(function ($) {
            //$('#PubDate,#EndDate').datepicker({ autoclose: true, format: "yyyy-mm-dd", language: "zh-CN" });
            $('#PubDate,#EndDate').datepicker({
                autoclose: true,
                todayHighlight: true,
                language: "zh-CN"
            });
            $('#CustomerId').select2(
   {
       minimumInputLength: 0,
       ajax: {

           quietMillis: 150,

           url: '/GsnService/GetJobCustomer/@Model.ParentId',
           dataType: 'json',
           data: function (term) {
               return {
                   term: term

               };
           },
           results: function (data, page) {

               return { results: data.Results };
           }
       },


       initSelection: function (element, callback) {

           var q = '@Model.CustomerId';
           if (q > 0) {
               $.ajax("/GsnService/GetJobCustomer/@Model.ParentId", {
                   data: {
                       initid: q
                   },
                   dataType: "json"

               }).done(function (data) {
                   var r = { id: data.Results[0].id, text: data.Results[0].text };
                   callback(r);

               });
           }
       },
   });
            $('#JobTypeId,#SalaryRange,#WorkExpe,#GenderReq,#EduBackground').select2();


        });
        function funBack() {
            document.location = "/JobInfoAll/Index/0?m=@ViewBag.m&f=@ViewBag.f&p=@ViewBag.p&fid=@ViewBag.fid&sdate=@ViewBag.sdate&edate=@ViewBag.edate&jname=@ViewBag.jname&pageIndex=@ViewBag.pageIndex";
        }
    </script>
}
